package com.jshcbd.modules.asset.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jshcbd.modules.asset.service.IAssetUseService;
import com.jshcbd.modules.asset.vo.AssetUseVo;
import com.jshcbd.modules.asset.entity.ReceiveEntity;
import com.jshcbd.modules.asset.entity.ReceiveItemEntity;
import com.jshcbd.modules.asset.mapper.ReceiveItemMapper;
import com.jshcbd.modules.asset.mapper.ReceiveMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author zhoucd
 * @date
 * @description
 */
@Slf4j
@Service
@Transactional
public class AssetUseServiceImpl extends ServiceImpl<ReceiveMapper, ReceiveEntity> implements IAssetUseService {

    @Autowired
    private ReceiveMapper receiveMapper;

    @Autowired
    private ReceiveItemMapper receiveItemMapper;


    @Override
    public IPage<ReceiveItemEntity> pageUseItemsByMainId(Page<ReceiveItemEntity> page, String mainId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("main_id",mainId);
        return receiveItemMapper.selectPage(page,queryWrapper);
    }

    @Override
    public IPage<AssetUseVo> pageViewByAssetId(Page<AssetUseVo> page, String assetId) {
        return receiveMapper.queryViewByAssetId(page,assetId);
    }

    @Override
    public IPage<AssetUseVo> pageView(Page<AssetUseVo> page, QueryWrapper<AssetUseVo> queryWrapper) {
        return receiveMapper.queryPageView(page,queryWrapper);
    }
}
